<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title id="title"></title>
    <link rel="stylesheet" href="layui/css/layui.css">

    <style>
        body {
            background:url(img/bbgg.jpg);
        }
    </style>
</head>
<body>
    <div class="layui-container" style="margin-top: 20px;">

        <div class="layui-col-xs12 layui-col-md6 layui-col-md-offset3">
            <div class="layui-card">
                <div class="layui-card-header"><h2 align="center" id="name" style="font-weight: bold"></h2></div>
                <div class="layui-card-body">
                    <!-- 图片 -->
                        <img id="picture">
                    </div>

                    <hr>

                    <div class="layui-form">
                        <table class="layui-table">
                            <colgroup>
                                <col width="150">
                                <col width="150">
                                <col width="200">
                                <col>
                            </colgroup>
                            <thead>
                            <tr>
                                <th>价格</th>
                                <th>简介</th>
                                <th>分类</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr style="height: 60px">
                                <td id="price"></td>
                                <td id="content"></td>
                                <td><span class="layui-badge layui-bg-orange" id="type" style="width: 30px"></span></td>
                            </tr>
                            </tbody>
                        </table>
                    </div>

                </div>
            </div>
        </div>

    </div>

    <script src="layui/layui.js" charset="utf-8"></script>
    <script>
        layui.use(['jquery'], function(){
            var $=layui.jquery;

            $(function (){
                var url = decodeURI(window.location.href);
                var argsIndex = url .split("?id=");
                var id = argsIndex[1];

                $.post('/goodsApi/get',{"id":id},function (res){
                    console.log(res);
                    var data=res.data;
                    $('#title').text(data.name);
                    $('#name').text(data.name);
                    $('#picture').attr({'src':data.picture,'width':'100%','height':'490px'});
                    $('#price').text(data.price);
                    $('#content').text(data.content);
                    $('#type').text(data.type.name);
                })
            })
        })
    </script>
</body>
</html>